package acm.europe2005.southwestern;

import java.util.Arrays;
import java.util.Scanner;


public class p2407 {
	
	static int N;
	static int[] A, B, C, D;
	static int[] X, Y;
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
//		Scanner scanner = new Scanner(new File("tests/11.in"));
		N = scanner.nextInt();
		A = new int[N];
		B = new int[N];
		C = new int[N];
		D = new int[N];
		X = new int[N*N];
		Y = new int[N*N];
		for (int i=0;i<N;++i) {
			A[i] = scanner.nextInt();
			B[i] = scanner.nextInt();
			C[i] = scanner.nextInt();
			D[i] = scanner.nextInt();
		}
		int x = 0;
		for (int i=0;i<N;++i) {
			for (int j=0;j<N;++j) {
				X[x] = A[i] + B[j];
				x++;
			}
		}
		int y = 0;
		for (int i=0;i<N;++i) {
			for (int j=0;j<N;++j) {
				Y[y] = -(C[i] + D[j]);
				y++;
			}
		}
		Arrays.sort(X);
		Arrays.sort(Y);
		x = y = 0;
		int count = 0;
		while (x < N*N && y < N*N) {
			int v = Math.min(X[x], Y[y]);
			if (v == X[x] && v == Y[y]) {
				int c1, c2;
				c1 = c2 = 0;
				while (x < N*N && X[x] == v) {
					++x; 
					++c1;
				}
				while (y < N*N && Y[y] == v) {
					++y;
					++c2;
				}
				count += c1 * c2;
			}
			else if (X[x] < Y[y]) ++x;
			else ++y;
		}
		System.out.println(count);
	}

}
